import i18n from "@/lang";

/**
 * 业务相关工具类
 */
export default class BusinessUtils {
    /**
     * 返回投资状态
     * @param {*} payStatus 支付状态
     * @param {*} productStaus 产品状态
     * @param {*} withdraw 赎回状态
     * @returns {number} 投资状态码 1. 进行中 2. 赎回中 3. 已赎回 0. 未匹配到
    */
    static getProductStatusCode(payStatus,productStaus,withdraw){
        if(payStatus == 3 && productStaus == 1 && withdraw == 0){
            return 1; // 进行中
        }else if(payStatus == 3 && productStaus == 1 && withdraw == 1){
            return 2; // 赎回中
        }else if(payStatus == 3 && productStaus == 2){
            return 3; // 已赎回
        }else{
            return 0; // 未匹配到
        }
    }

    /**
     * 根据套餐ID获取套餐名称
     * @param {*} productId 套餐ID
     * @returns 
     */
    static getProductNameById(productId) {
        let productIdToName = {
            "1": i18n.t("专属权益"),
            "2": "L1",
            "3": "L2",
            "4": "L3",
            "5": "L4",
        }
        return productIdToName[productId] || "";
    }

    static getInvitePath(domain, inviteCode) {
        let separator = domain.endsWith('/') ? '' : '/';
        return `${domain}${separator}#/transfer/registerAccount?invite_code=${inviteCode}`;
    }

    static getLevelIcon(levelId) {
        let levelIdToImage = {
            0: require("@/image/personalCenter/s0.png"),
            1: require("@/image/personalCenter/s1.png"),
            2: require("@/image/personalCenter/s2.png"),
            3: require("@/image/personalCenter/s3.png"),
            4: require("@/image/personalCenter/s4.png"),
            5: require("@/image/personalCenter/t1.png"),
            6: require("@/image/personalCenter/t2.png"),
            7: require("@/image/personalCenter/t3.png"),
            8: require("@/image/personalCenter/t4.png"),
        }
        return levelIdToImage[levelId] || require("@/image/personalCenter/s0.png");
    }

    static getLevelName(levelId) {
        let levelIdToName = {
            0: "S0",
            1: "S1",
            2: "S2",
            3: "S3",
            4: "S4",
            5: "T1",
            6: "T2",
            7: "T3",
            8: "T4",
        }
        return levelIdToName[levelId] || i18n.t("普通会员");
    }

    static getCoinIcon(coinName) {
        let image;
        let upperName = coinName.toUpperCase();
        try{
            //平台币种
            if(upperName == 'SAT' || upperName == 'SUSD'){
                image = require('@/image/global/coinIcon/app/'+upperName+'.png')
            }else{//其他币种
                image = require('@/image/global/coinIcon/'+upperName+'.png')
            }
        }catch(e){
        }
        
        return image;
    }
}